package org.jetnuke.modules.admin.blocks;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.velocity.VelocityContext;
import org.jetnuke.common.ActionForward;
import org.jetnuke.common.Configuration;
import org.jetnuke.common.IAction;
import org.jetnuke.common.IAdminInfo;
import org.jetnuke.common.IModuleInfo;
import org.jetnuke.common.IUserInfo;
import org.jetnuke.dao.DataAccessDriver;
import org.jetnuke.util.JetUtil;

public class BlockActivate implements IAction {
	int bid;

	public ActionForward exec(HttpServletRequest request,
			HttpServletResponse response, VelocityContext vc, IModuleInfo info,
			String op, IUserInfo ui, IAdminInfo ai) throws Exception {

		if (ai == null || !ai.IsSuperUser())
			return null;//Error;
		DataAccessDriver.getInst().newBlockDAO().blockActivate(bid);
		//blocks blk = blocksPeer.retrieveByPK(bid);
		//blk.setACTIVE(1);
		//blk.save();
		Configuration cfg = new Configuration(request.getSession(true).getServletContext());
		request.getSession(true).getServletContext().setAttribute("_cfg", cfg);
		JetUtil.redirect(vc,response,request.getContextPath()+"/do/admin/show_blocks");
		return null;

	}

	public int getBid() {
		return bid;
	}

	public void setBid(int bid) {
		this.bid = bid;
	}
}
